<template>
  <div :class="['todo-item', todo.completed ? 'completed' : '']">
    <input
      type="checkbox"
      class="toggle"
      v-model="todo.completed"
    />
    <label>{{todo.content}}</label>
    <button class="destroy " @click="deleteTodo(todo.id)"></button>
  </div>
</template>
<script>
export default {
  props: {
    todo: {
      type: Object,
      required: true
    }
  },
  methods: {
    deleteTodo(id) {
      this.$emit('del', id)
    }
  }
}
</script>
<style lang="stylus" scoped>
.todo-item  
  position relative
  background #ffffff
  font-size 24px
  border-bottom 1px solid rgba(0,0,0,.06)
  &:hover
    .destroy:after {
         content: '×'
    }
     
  label  
    white-space pre-line
    word-break break-all
    padding 15px 60px 15px 15px
    margin-left 45px
    display block 
    line-height 1.2
    transition color 0.4s
&.completed{
    color #d9d9d9
    text-decoration line-through
}
.toggle{
  text-align center 
  width 400px
  height 40px
  position absolute
  top 0
  bottom 0
  margin auto 0
  border none 
  outline none 
  appearance none
}
  .toggle:before{
    content: ''
    width 40px
    height 40px
    background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23ededed%22%20stroke-width%3D%223%22/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: center left;
    position absolute
    left 12px
    cursor pointer
  }
  .toggle:checked:before{
    background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23bddad5%22%20stroke-width%3D%223%22/%3E%3Cpath%20fill%3D%22%235dc2af%22%20d%3D%22M72%2025L42%2071%2027%2056l-4%204%2020%2020%2034-52z%22/%3E%3C/svg%3E');
    position absolute
    left 12px
    cursor pointer
  }
.destroy
  position absolute
  top 50%
  right 10px
  bottom 0;
  width 40px
  height 40px
  margin auto 0
  font-size 30px
  color #cc9a9a
  margin-bottom 11px
  transition: color 0.2s east-out
  background-color transparent
  appearance none
  border-width 0
  cursor pointer
  outline none
</style>

